package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import persistence.Axdbv4HibernateManager;

public class BlackListServlet extends HttpServlet{

	/**
	 * Servlet per l'aggiornamento del campo "isBlackListed" 
	 * dei record nella tab. representationsName
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		resp.setContentType("text/html; charset=UTF-8");
		this.doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		resp.setContentType("text/html; charset=UTF-8");
		long NID=Long.valueOf((String)req.getParameter("NID"));
		boolean isBlackListed=Boolean.valueOf((String) req.getParameter("isBlackListed"));
		System.out.println("Avviata BlackListServlet per NID:"+NID+ ", is blackList: "+ isBlackListed);
		Axdbv4HibernateManager dbManager=Axdbv4HibernateManager.getIstance();
		dbManager.updateBlackListRepresentationNameRecord(NID, isBlackListed);
	}
}
